package com.example.jiaju.ui;

import android.os.Bundle;

import androidx.constraintlayout.helper.widget.Carousel;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.example.jiaju.R;


public class DecorationFragment extends Fragment {


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view=inflater.inflate(R.layout.fragment_decoration, container, false);

        int images[] = {
                R.drawable.building1,
                R.drawable.building2,
                R.drawable.furniture1,
                R.drawable.building3
        };

        Carousel carousel = view.findViewById(R.id.carousel);
        carousel.setAdapter(new Carousel.Adapter() {
            @Override
            public int count() {
                // need to return the number of items we have in the carousel
                return 4;
            }

            @Override
            public void populate(View view, int index) {
                if (view instanceof ImageView){
                    ((ImageView) view).setImageResource(images[index]);
                }

                // need to implement this to populate the view at the given index
            }

            @Override
            public void onNewItem(int index) {
                // called when an item is set
            }
        });

        return view;
    }
}